[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
     local(LIST)

             Declares the listed variables to  be  local  to  the
             enclosing  block, subroutine, eval or "do".  All the
             listed elements must be legal lvalues.  This  opera-
             tor  works  by  saving  the  current values of those
             variables in LIST on a hidden  stack  and  restoring
             them  upon  exiting  the  block, subroutine or eval.

             This means that called subroutines can  also  refer-
             ence  the  local  variable,  but not the global one.
             The LIST may be assigned to if desired, which allows
             you to initialize your local variables.  (If no ini-
             tializer is given for a particular variable,  it  is
             created  with an undefined value.)  Commonly this is
             used to name the parameters to a subroutine.   Exam-
             ples:

                  sub RANGEVAL {
                       local($min, $max, $thunk) = @_;
                       local($result) = '';
                       local($i);

                       # Presumably $thunk makes reference to $i

                       for ($i = $min; $i < $max; $i++) {
                            $result .= eval $thunk;
                       }

                       $result;
                  }

                  if ($sw eq '-v') {
                      # init local array with global array
                      local(@ARGV) = @ARGV;
                      unshift(@ARGV,'echo');
                      system @ARGV;
                  }
                  # @ARGV restored

                  # temporarily add to digits associative array
                  if ($base12) {
                       # (NOTE: not claiming this is efficient!)
                       local(%digits) = (%digits,'t',10,'e',11);
                       do parse_num();
                  }

             Note that local() is a run-time command, and so gets
             executed  every  time  through a loop, using up more
             stack storage each time until it's all  released  at
             once when the loop is exited.

This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson